﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace ModuleDuoc
{
    public partial class frmShowReport : Form
    {
        public static DataTable _dt;
        public static DataTable _dt1;
        public static string _title;
        public static string _phongban;
        public static string _nhanvien;
        public static string _ghichu;
        public static string _thanhtien;
        public static string _sophieu;
        public static string _sohd;
        public static string _trietkhau;
        public static string _tongtien;
        public static string _tenKH;
        public static string _tuoiKH;
        public static string _diachiKH;
        public static string _nhacungcap;
        public static string _vat;
        public static string _bangchu;
        public static string _tungay;
        public static string _denngay;
        int _type;
        public static string _typeTrietKhau;
        public static string _tonglai;
        public static string _tongban;
        public static BC strC = new BC();
        public static string _date1;
        public static string _date2;
        //Bien ban kiem ke
        public static string _thoiGian;
        public static string _thang;
        public static string _nam;
        public static string _boYte;
        public static string _benhVien;
        public static string _khoa;
        public static string _ms;
        public static string _so;
        public static string _ten1;
        public static string _ten2;
        public static string _ten3;
        public static string _ten4;
        public static string _ten5;
        public static string _chucDanh1;
        public static string _chucDanh2;
        public static string _chucDanh3;
        public static string _chucDanh4;
        public static string _chucDanh5;
        public static string _deXuat;
        public static string _am;
        public static string _tongnhap;
        public static string _laixuat;
        //public static string _sltong;
        //public static string _tientong;

        public enum BC
        {
            PHIEUNHAPHANG = 1,
            PHIEUKIEMKEDAUKY = 2,
            HOADONBANLE = 3,
            HOADONBANBUON = 4,
            PHIEUXUATKHONOIBO = 5,
            PHIEUXUATHUY = 6,
            PHIEUNHAPHANGTRALAI = 7,
            DONTHUOC = 8,
            TKXUATHANG = 9,
            TKNHAPHANG = 10,
            BAOCAOKIEMNHAP = 11,
            HEAD_BAOCAOKIEMNHAP=12,
            TKXUATHANG_THANG = 13,
            TKTHUOCTRALAI=14,
            TONGHOPXNTON=15,
            PHIEUTRALAI=16,
            BIENBANKIEMKETHUOC=17,
            BAOCAOSUDUNGTHUOC = 18,
            DUTRUMUATHUOC = 19,
            TONGHOPTONKHO_AT = 20,
            TONGHOPTHUOCBIAM_AT = 21,
            InMaVach = 22,
            TONGHOPNHAPHANG = 23
        }
        public frmShowReport(int type)
        {
            InitializeComponent();
            _type = type;
        }

        private void frmShowReport_Load(object sender, EventArgs e)
        {
            loadBC(strC);
        }
        private void loadBC(BC strC)
        {
            if (BC.PHIEUKIEMKEDAUKY == strC)
            {
                this.Text = "PHIẾU NHẬP HÀNG KIÊM KIỂM KÊ ĐẦU KỲ";
                Report.rpt_NhapHang rpt = new ModuleDuoc.Report.rpt_NhapHang();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("title", "PHIẾU NHẬP HÀNG");
                rpt.SetParameterValue("phongban", _phongban);
                rpt.SetParameterValue("hoten", _nhanvien);
                rpt.SetParameterValue("sophieu", _sophieu);
                rpt.SetParameterValue("ghichu", _ghichu);
                rpt.SetParameterValue("thanhtien", _thanhtien);
                rpt.SetParameterValue("trietkhau", _trietkhau);
                rpt.SetParameterValue("tongtien", _tongtien);
                rpt.SetParameterValue("sohd", _sohd);
                rpt.SetParameterValue("type", _typeTrietKhau);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.PHIEUNHAPHANG == strC)
            {
                this.Text = "PHIẾU NHẬP HÀNG";
                Report.rpt_NhapHang rpt = new ModuleDuoc.Report.rpt_NhapHang();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("phongban", _phongban);
                rpt.SetParameterValue("hoten", _nhanvien);
                rpt.SetParameterValue("sophieu", _sophieu);
                rpt.SetParameterValue("ghichu", _ghichu);
                rpt.SetParameterValue("sohd", _sohd);
                rpt.SetParameterValue("tongtien", _tongtien);
                rpt.SetParameterValue("nhacungcap", _nhacungcap);
                rpt.SetParameterValue("tienvat", _vat);
                rpt.SetParameterValue("bangchu", _bangchu);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.HOADONBANLE == strC)
            {
                this.Text = "HÓA ĐƠN BÁN LẺ";
                Report.rpt_XuatHang rpt = new ModuleDuoc.Report.rpt_XuatHang();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("thanhtien", _thanhtien);
                rpt.SetParameterValue("tennhanvien", _nhanvien);
                rpt.SetParameterValue("tenKH", _tenKH);
                rpt.SetParameterValue("diachiKH", _diachiKH);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.DONTHUOC == strC)
            {
                this.Text = "ĐƠN THUỐC";
                Report.rpt_DonThuoc rpt = new ModuleDuoc.Report.rpt_DonThuoc();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tenbacsi", _nhanvien);
                rpt.SetParameterValue("tenKH", _tenKH);
                rpt.SetParameterValue("tuoiKH", _tuoiKH);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TKXUATHANG == strC)
            {
                this.Text = "BÁO CÁO XUẤT HÀNG";
                Report.rpt_TKXuatHangMaVach rpt = new ModuleDuoc.Report.rpt_TKXuatHangMaVach();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tungay", _tungay);
                rpt.SetParameterValue("denngay", _denngay);
                rpt.SetParameterValue("tongban", _thanhtien);
                rpt.SetParameterValue("tonglai", _tonglai);
                //rpt.SetParameterValue("title", _title);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TKXUATHANG_THANG == strC)
            {
                this.Text = "BÁO CÁO XUẤT HÀNG";
                Report.rpt_TKXuatHang rpt = new ModuleDuoc.Report.rpt_TKXuatHang();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tungay", _tungay);
                rpt.SetParameterValue("denngay", _denngay);
                rpt.SetParameterValue("tongban", _thanhtien);
                rpt.SetParameterValue("tonglai", _tonglai);
                rpt.SetParameterValue("title", _title);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TKNHAPHANG == strC)
            {
                this.Text = "BÁO CÁO NHẬP HÀNG";
                Report.rpt_TKNhapHang rpt = new ModuleDuoc.Report.rpt_TKNhapHang();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tungay", _tungay);
                rpt.SetParameterValue("denngay", _denngay);
                rpt.SetParameterValue("tongnhap", _thanhtien);
                rpt.SetParameterValue("tonglai", _tonglai);
                rpt.SetParameterValue("tongban", _tongban);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.BAOCAOKIEMNHAP == strC)
            {
                this.Text = "BÁO CÁO KIỂM NHẬP";
                Report.rpt_SoKiemNhap rpt = new ModuleDuoc.Report.rpt_SoKiemNhap();
                rpt.SetDataSource(_dt);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.HEAD_BAOCAOKIEMNHAP == strC)
            {
                this.Text = "TIÊU ĐỀ BÁO CÁO KIỂM NHẬP";
                Report.rpt_Head_SoKiemNhap rpt = new ModuleDuoc.Report.rpt_Head_SoKiemNhap();
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TKTHUOCTRALAI == strC)
            {
                this.Text = "DANH SÁCH THUỐC TRẢ LẠI";
                Report.BC_ThuocTraLai_New rpt = new ModuleDuoc.Report.BC_ThuocTraLai_New();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("date1", _date1);
                rpt.SetParameterValue("date2", _date2);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TONGHOPXNTON == strC)
            {
                this.Text = "TỔNG HỢP XUẤT NHẬP TỒN KHO DƯỢC";
                Report.rpt_BC_TongHop rpt = new ModuleDuoc.Report.rpt_BC_TongHop();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tungay", _date1);
                rpt.SetParameterValue("denngay", _date2);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.BIENBANKIEMKETHUOC == strC)
            {
                this.Text = "BIÊN BẢN KIỂM KÊ THUỐC";
                Report.rpt_BienBanKiemKeThuoc rpt = new ModuleDuoc.Report.rpt_BienBanKiemKeThuoc();
                rpt.SetDataSource(_dt1);
                //rpt.Subreports[0].SetDataSource(_dt);
                //rpt.Subreports[1].SetDataSource(_dt1);

                rpt.SetParameterValue("thoigian", _thoiGian);
                rpt.SetParameterValue("thang", _thang);
                rpt.SetParameterValue("nam", _nam);

                rpt.SetParameterValue("BoYte", _boYte);
                rpt.SetParameterValue("BenhVien", _benhVien);
                rpt.SetParameterValue("Khoa", _khoa);
                rpt.SetParameterValue("MS", _ms);
                rpt.SetParameterValue("So", _so);

                rpt.SetParameterValue("Ten1", _ten1);
                rpt.SetParameterValue("Ten2", _ten2);
                rpt.SetParameterValue("Ten3", _ten3);
                rpt.SetParameterValue("Ten4", _ten4);
                rpt.SetParameterValue("Ten5", _ten5);

                rpt.SetParameterValue("ChucDanh1", _chucDanh1);
                rpt.SetParameterValue("ChucDanh2", _chucDanh2);
                rpt.SetParameterValue("ChucDanh3", _chucDanh3);
                rpt.SetParameterValue("ChucDanh4", _chucDanh4);
                rpt.SetParameterValue("ChucDanh5", _chucDanh5);

                rpt.SetParameterValue("DeXuat", _deXuat); 
                rpt.SetParameterValue("date1", _date1); 
                rpt.SetParameterValue("date2", _date2);

                crvViewer.ReportSource = rpt;
            }
            else if (BC.BAOCAOSUDUNGTHUOC == strC)
            {
                this.Text = "BÁO CÁO SỬ DỤNG THUỐC";
                Report.rpt_BC_SuDungThuoc rpt = new ModuleDuoc.Report.rpt_BC_SuDungThuoc();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("thoigian", _thoiGian);
                rpt.SetParameterValue("BoYte", _boYte);
                rpt.SetParameterValue("BenhVien", _benhVien);
                rpt.SetParameterValue("MS", _ms);
                rpt.SetParameterValue("So", _so);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.DUTRUMUATHUOC == strC)
            {
                this.Text = "BÁO CÁO DỰ TRÙ THUỐC";
                Report.rpt_DuTruThuoc rpt = new ModuleDuoc.Report.rpt_DuTruThuoc();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("thoigian", _thoiGian);
                rpt.SetParameterValue("nguoilap", _nhanvien);
                rpt.SetParameterValue("phongban", _phongban);
                rpt.SetParameterValue("So", _so);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.PHIEUTRALAI == strC)
            {
                this.Text = "PHIẾU TRẢ LẠI THUỐC";
                Report.rpt_PhieuTraLai rpt = new ModuleDuoc.Report.rpt_PhieuTraLai();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("BangChu", _thanhtien);
                rpt.SetParameterValue("date1", _date1);
                //rpt.SetParameterValue("date2", _date2);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TONGHOPTONKHO_AT == strC)
            {
                this.Text = "TỔNG HỢP TỒN KHO";
                Report.rpt_TongHopTonKhoThuoc_AT rpt = new ModuleDuoc.Report.rpt_TongHopTonKhoThuoc_AT();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("thoiGian", _thoiGian);
                rpt.SetParameterValue("am", _am);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TONGHOPTHUOCBIAM_AT == strC)
            {
                this.Text = "TỔNG HỢP THUỐC BỊ ÂM";
                Report.rpt_TongHopThuocBiAm_AT rpt = new ModuleDuoc.Report.rpt_TongHopThuocBiAm_AT();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("thoiGian", _thoiGian);
                rpt.SetParameterValue("am", _am);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.InMaVach == strC)
            {
                this.Text = "IN MÃ VẠCH";
                Report.rpt_123 rpt = new ModuleDuoc.Report.rpt_123();
                rpt.SetDataSource(_dt);
                crvViewer.ReportSource = rpt;
            } 
             else if (BC.TONGHOPNHAPHANG == strC)
            {
                this.Text = "BÁO CÁO TỔNG HỢP NHẬP HÀNG";
                Report.BC_TongHopNhapHang rpt = new ModuleDuoc.Report.BC_TongHopNhapHang();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tongtiennhap", _tongnhap);
                rpt.SetParameterValue("tongtienban", _tongban);
                rpt.SetParameterValue("laixuat", _laixuat);
                rpt.SetParameterValue("tungay", _tungay);
                rpt.SetParameterValue("denngay", _denngay);
                rpt.SetParameterValue("nguoinhap", _nhanvien);
                crvViewer.ReportSource = rpt;
            }
            else if (BC.TKXUATHANG == strC)
            {
                this.Text = "BÁO CÁO XUẤT HÀNG";
                Report.rpt_TKXuatHangMaVach rpt = new ModuleDuoc.Report.rpt_TKXuatHangMaVach();
                rpt.SetDataSource(_dt);
                rpt.SetParameterValue("tungay", _tungay);
                rpt.SetParameterValue("denngay", _denngay);
                rpt.SetParameterValue("tongban", _thanhtien);
                rpt.SetParameterValue("tonglai", _tonglai);
                crvViewer.ReportSource = rpt;
            }
        }
    }
}
